﻿using System;
using System.Collections.Generic;

namespace Sissonix.ExtRest.Serialization
{
    /// <summary>
    /// Class that handles storage of serializers and deserializers.
    /// </summary>
    public static class SerializationTable
    {
        /// <summary>
        /// Gets the serializers.
        /// </summary>
        /// <value>The serializers.</value>
        public static Dictionary<string, ISerializer> Serializers { get; private set; }

        static SerializationTable()
        {
            Serializers = new Dictionary<string, ISerializer>
                              {
                                  {MimeTypes.APPLICATION_JSON, new JsonSerializer()},
                                  {MimeTypes.TEXT_XML, new XmlSerializer()},
                                  {MimeTypes.APPLICATION_X_WWW_FORM_URLENCODED, new XWwwFormUrlEncodedSerializer()}
                              };
            Serializers.Add(MimeTypes.APPLICATION_JAVASCRIPT, Serializers[MimeTypes.APPLICATION_JSON]);
            Serializers.Add(MimeTypes.APPLICATION_JSON_JAVASCRIPT, Serializers[MimeTypes.APPLICATION_JSON]);
            Serializers.Add(MimeTypes.APPLICATION_XML, Serializers[MimeTypes.TEXT_XML]);
            Serializers.Add(MimeTypes.TEXT_JAVASCRIPT, Serializers[MimeTypes.APPLICATION_JSON]);
        }
    }
}
